package com.bayern.struts.one.action;

import com.bayern.struts.one.annotation.ActionAnnotation;
import com.bayern.struts.one.annotation.ResultAnnotation;
import com.bayern.struts.one.bean.LoginPojo;
import com.bayern.struts.one.servlet.util.ResultType;

public class LoginAction
{
	@ActionAnnotation(ActionName="login.action",results={@ResultAnnotation(name=ResultType.SUCCESS,value="index.jsp"),@ResultAnnotation(name=ResultType.LOGIN,value="login.jsp")})
	public ResultType login(String name, String password)
	{
		if("hello".equals(name) && "world".equals(password))
		{
			return ResultType.SUCCESS;
		}
		return ResultType.LOGIN;
	}
	
	@ActionAnnotation(ActionName="loginForUser.action",results={@ResultAnnotation(name=ResultType.SUCCESS,value="index.jsp"),@ResultAnnotation(name=ResultType.LOGIN,value="login.jsp")})
	public ResultType loginForUser(int number, LoginPojo loginPojo)
	{
		if("hello".equals(loginPojo.getUsername()) && "world".equals(loginPojo.getPassword()))
		{
			return ResultType.SUCCESS;
		}
		return ResultType.LOGIN;
	}
}
